﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls.Primitives;
using CommunityToolkit.Mvvm.Input;

namespace NextMachine
{
    public partial class MainViewModel : WindowViewModelBase
    {
        private ResourceDictionary _lightTheme;
        private ResourceDictionary _darkTheme;
        public MainViewModel()
        {
            this.WindowCaption = "NextMachine";
            this._lightTheme = new ResourceDictionary();
            this._lightTheme.Source = new Uri("/ZeroBug.EasyFlow.Resources;component/Themes/LightTheme.xaml", UriKind.RelativeOrAbsolute);
            this._darkTheme = new ResourceDictionary();
            this._darkTheme.Source = new Uri("/ZeroBug.EasyFlow.Resources;component/Themes/DarkTheme.xaml", UriKind.RelativeOrAbsolute);
        }
        [RelayCommand]
        void WindowClose(object obj)
        {
            Window? window = obj as Window;
            if (window != null)
            {
                window.Close();
            }
        }
        [RelayCommand]
        void ChangeTheme(object obj)
        {
            if (obj != null)
            {
                if ((Boolean)obj)
                {
                    App.Current.Resources.MergedDictionaries.Remove(_darkTheme);
                    App.Current.Resources.MergedDictionaries.Add(_darkTheme);
                }
                else
                {
                    App.Current.Resources.MergedDictionaries.Remove(_lightTheme);
                    App.Current.Resources.MergedDictionaries.Add(_lightTheme);
                }
            }
        }
    }
}
